<?php

    $selected_cat_setting = array(
    'table_name' => 'zoo_categories',
    'key_field' => 'id',
    'value_field' => 'nomfr',
    'where'=> array('parent >'=>0)
    );
    if($query_product->num_rows()>0){
        $row=$query_product->row();
        $selected_cat=$row->catid;
    }
    $image_path = './assets/photos/' . $row->img;
    if ($row->img != '') {
        if (file_exists($image_path)) {
            $image_path = base_url() . 'assets/photos/' . $row->img; 
        } else {
            $image_path = root_url('zoo-market') . 'assets/noimage.gif';
        }
    } else {
        $image_path = root_url('zoo-market') . 'assets/noimage.gif';
} ?>

<div id="wrapper-content">
     <table class="titrepage" width="100%">
        <tr>
            <td >Information du produit</td>
          </tr>
    </table>
        <?php echo form_open_multipart(site_url('product_admin/edit_product'. '/' . $row->id)); ?>
        <table align="center" width="100%" class="list" cellpadding="10px" cellspacing="0">
            <tr>
                <td>Nom:</td>
                <td><input type="text" name="name" size="30" value="<?php echo $row->nomfr; ?>">
                <?php echo form_error('name') ?></td>     
            </tr>
            <tr>
                <td >Image:</td>
                <td><img src="<?php echo $image_path;?>" height="80"/><input size="30" type="file" name="userfile" id="userfile" size="25"/></td>

            </tr>
            <tr>
                <td>Categorie:</td>
                <td><?php echo form_dropdown('cat_id',dropdown_data($selected_cat_setting),$selected_cat);?></td>

            </tr>
            <tr>
                <td>Quantité:</td>
                <td><input type="text" size="30" name="quantity" value="<?php echo $row->quantite; ?>">
                <?php echo form_error('quantity') ?><td>    
            </tr>
            <tr>
                <td>Prix:</td>
                <td><input type="text" size="30" name="price"  value="<?php echo $row->prix; ?>">
                <?php echo form_error('price') ?><td>    
            </tr>
            <tr>
                <td>Poids:</td>
                <td><input type="text" size="30" name="poids"  value="<?php echo $row->poids; ?>">
                <?php echo form_error('poids') ?><td>
            </tr>
            <tr>
                <td width="30%" >Description:</td>
                <td colspan="2">
                    <?php
                        $data = array('name' => 'description',
                        'id' => 'description',
                        'width' => '600',
                        'height' => '250',
                        'value' => $row->descriptionfr,
                        'type' =>'text'
                        );
                        echo form_fckeditor($data);
                    ?>
                    <?php echo form_error('description'); ?>
                </td>

            </tr>
            <tr>
                <td>Promo:</td>
                <td><input type="text" size="30" name="promo" value="<?php echo  $row->promo; ?>">
                <?php echo form_error('promo'); ?></td>
            </tr>
            <tr>
                <td>
                    <?php
                        $aCoeur=$row->coeur;
                        $coeur = array(
                        'name'        => 'coeur',
                        'id'          => 'coeur',
                        'value'       => 1,
                        'checked'     => $aCoeur ==1 ? TRUE:FALSE,
                        'style'       => 'margin:10px',
                        );
                        echo 'Coeur'.form_checkbox($coeur);
                    ?>
                </td>

            </tr>
            <tr>
                <td></td> <td><input type="submit" name="submit" value=" Enregistrer "/></td>
            </tr>
        </table>

    <?php echo form_close(); ?>

</div>
